package au.com.helloweb.androidgamepractice;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.MotionEvent;
import android.view.View;

public class MyView extends View {
	int textX = 100;
	int textY = 100;

	public MyView(Context context){
		super(context);
		setFocusable(true);
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		Paint paint = new Paint();
		paint.setColor(Color.BLACK);
		paint.setTextSize(18);
		canvas.drawText("Game", textX, textY, paint);
		super.onDraw(canvas);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		int x = (int)event.getX();
		int y = (int)event.getY();
		if(event.getAction() == MotionEvent.ACTION_DOWN){
			textX = x;
			textY = y;
		}else if(event.getAction() == MotionEvent.ACTION_MOVE){
			textX = x;
			textY = y;
		}else if(event.getAction() == MotionEvent.ACTION_UP){
			textX = x;
			textY = y;
		}
		this.invalidate();
		// TODO Auto-generated method stub
		return true;
	}
	
}
